﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoreProvince;
using CoreNhaDat;

namespace BatDongSan.Ucs
{
    public partial class NhaDatDetail : System.Web.UI.UserControl
    {
        int _id;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                _id = Convert.ToInt32(Request.QueryString["id"]);
                if (!IsPostBack)
                {

                    LoadData(_id);
                }
            }
            catch
            {
            }
        }

        protected void LoadData(int id)
        {
            VG_NhaDat Info = PlaceBll.GetVGNhaDatById(id, Utility.strConnect);
            string temp = NhaDatBll.GetNameById(Convert.ToInt32(Info.NhaDatId), Utility.strConnect);
            lbDescriptionTitle.Text = "Mô tả " + temp;
            lbThongTinNhaBanTitle.Text = "Thông tin " + temp;
            lbLink.Text = "Chi tiết " + temp;

            

            ltrDescription.Text = Info.Description;
            if (Info.Price > 0)
                ltrPrice.Text = String.Format("{0:0,0}", Info.Price) + " " + Info.PriceUnit;
            else
                ltrPrice.Text = "Thương lượng";

            lbName.Text = Info.Name;
            lbAddress.Text = Info.Address;
            lbDateBegin.Text = string.Format("{0:dd/MM/yyyy}", Info.DateBegin);
            lbDateEnd.Text = string.Format("{0:dd/MM/yyyy}", Info.DateEnd);
            lbEmail.Text = Info.UserEmail;
            lbHuongNha.Text = Info.HuongNha;
            lbPhone.Text = Info.UserPhone + " - " + Info.UserTelephone;
            lbProject.Text = "";
            lbProvince.Text = WardBll.GetById((int)Info.WardId, Utility.strConnect).Name + " , " + ProvinceBll.GetById((int)Info.ProvinceId, Utility.strConnect).Name;
            if (Info.SoPhong > 0)
                lbSoPhong.Text = Info.SoPhong.ToString();
            else
                lbSoPhong.Text = "";
            lbUserAddress.Text = Info.UserAddress;
            lbUserName.Text = Info.UserName;
            ldId.Text = Info.Id.ToString();
        }
    }
}